<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// Route::middleware('auth:api')->get('/user', function (Request $request) {
//     return $request->user();
// });

// Route::any('/wechat/server', 'Api\WeChatController@server')->name('server');


//静默授权登录
// Route::any('/wechat/login', ['uses' => 'Api\WeChatController@login', 'as' => 'api.wechat.login'])->middleware(['web', 'cors', 'wechat.oauth']);

// // 获取微信信息
// Route::any('/wechat/getWxInfo', ['uses' => 'Api\WeChatController@getWxInfo', 'as' => 'api.wechat.getWxInfo'])->middleware(['web', 'cors','wechat.oauth:default,snsapi_userinfo']);

// // 获取微信配置
// Route::post('/wechat/getWxConfig', ['uses' => 'Api\WeChatController@getWxConfig', 'as' => 'api.wechat.getWxConfig'])->middleware(['cors']);


// 无需授权
Route::group(['middleware' => ['cors'],'namespace' => 'Api'], function ($api) {

    // 会员登录
    Route::post('/member/login', ['uses' => 'MemberController@login', 'as' => 'api.member.login']);

    // 商品列表
    Route::post('/goods/list', ['uses' => 'GoodsController@list', 'as' => 'api.goods.list']);

    // 商品详情
    Route::post('/goods/info', ['uses' => 'GoodsController@info', 'as' => 'api.goods.info']);

    // 商品分类
    Route::post('/goods/category', ['uses' => 'GoodsController@category', 'as' => 'api.goods.category.list']);

    // 轮播图接口
    Route::post('/slideshow/list', ['uses' => 'ShopController@slideshowList', 'as' => 'api.slideshow.list']);

    // 支付方式列表
    Route::post('/payment/list', ['uses' => 'ShopController@paymentList', 'as' => 'api.payment.list']);

    // 支付回调
    // Route::post('/payment/notify', ['uses' => 'PaymentController@notify', 'as'=>'api.payment.notify']);
    // Route::post('/payment/return', ['uses' => 'PaymentController@return', 'as'=>'api.payment.return']);

    // 连连付支付回调
    Route::post('/payment/llpay_notify', ['uses' => 'PaymentController@llpay_notify', 'as'=>'api.payment.llpay_notify']);
    // Route::post('/payment/llpay_return', [PaymentController::class, 'llpay_return', 'as'=>'api.payment.llpay_return']);

    // 检测订单支付状态
    Route::post('/order/checkOrderPay', ['uses' => 'OrderController@checkOrderPay', 'as'=>'api.order.checkOrderPay']);


});

// 需授权
Route::group(['middleware' => ['cors', 'jwt.api.auth'],'namespace' => 'Api'], function ($api) {

    // 会员退出
    Route::post('/member/logout', ['uses' => 'MemberController@logout', 'as' => 'api.member.logout']);

    // 获取会员信息
    Route::get('/member/info', ['uses' => 'MemberController@getInfo', 'as' => 'api.member.info']);
    // 获取openid
    Route::post('/member/getOpenId', ['uses' => 'MemberController@getOpenId', 'as' => 'api.member.getOpenId']);

    // 获取会员收货地址列表
    Route::post('/member/address', ['uses' => 'MemberController@memberAddress', 'as' => 'api.member.address']);

    // 添加/编辑会员收货地址
    Route::post('/member/saveAddress', ['uses' => 'MemberController@saveAddress', 'as' => 'api.member.saveAddress']);

    // 删除收货地址
    Route::post('/member/deleteAddress', ['uses' => 'MemberController@deleteAddress', 'as' => 'api.member.deleteAddress']);

    // 购物车列表
    Route::post('/cart/list', ['uses' => 'CartController@list', 'as' => 'api.cart.list']);

    // 获取购物车数量
    Route::post('/cart/count', ['uses' => 'CartController@count', 'as' => 'api.cart.count']);

    // 加入/编辑购物车
    Route::post('/cart/add', ['uses' => 'CartController@add', 'as' => 'api.cart.add']);

    // 删除购物车记录
    Route::post('/cart/delete', ['uses' => 'CartController@delete', 'as' => 'api.cart.delete']);

    // 编辑会员信息
    Route::post('/member/update', ['uses' => 'MemberController@update', 'as' => 'api.member.update']);

    // 积分明细
    // Route::post('/member/score/list', ['uses' => 'MemberController@scoreList', 'as' => 'api.member.score.list']);

    // 会员绑定管理员信息
    // Route::post('/member/bind', ['uses' => 'MemberController@getBindInfo', 'as' => 'api.member.bind.info']);

    // 订单列表
    Route::post('/order/list', ['uses' => 'OrderController@list', 'as' => 'api.order.list']);

    // 订单详情
    Route::post('/order/info', ['uses' => 'OrderController@info', 'as' => 'api.order.info']);

    // 创建订单
    Route::post('/order/create', ['uses' => 'OrderController@create', 'as' => 'api.order.create']);

    // 取消订单
    Route::post('/order/cancel', ['uses' => 'OrderController@cancel', 'as' => 'api.order.cancel']);

    // 订单数量统计
    Route::post('/order/count', ['uses' => 'OrderController@count', 'as' => 'api.order.count']);

    // 获取结算价格
    Route::post('/order/getPrice', ['uses' => 'OrderController@getPrice', 'as' => 'api.order.getPrice']);

    // 去支付
    Route::post('/order/toPay', ['uses' => 'OrderController@toPay', 'as' => 'api.order.toPay']);


    // 我的活动
    // Route::post('/activity/myactivity', ['uses' => 'ActivityController@myactivity', 'as' => 'api.activity.myactivity']);

    // 参与活动
    // Route::post('/activity/create', ['uses' => 'ActivityController@create', 'as' => 'api.activity.create']);

    // 活动取消
    // Route::post('/activity/cancel', ['uses' => 'ActivityController@cancel', 'as' => 'api.activity.cancel']);

    // 用户扫描活动码签到
    // Route::post('/activity/singin/member', ['uses' => 'ActivityController@singinFromMember', 'as' => 'api.activity.singin.member']);

    // 活动详情
    // Route::post('/activity/info', ['uses' => 'ActivityController@info', 'as' => 'api.activity.info']);

});


// 需授权 操作员
// Route::group(['middleware' => ['cors', 'jwt.api.auth'],'namespace' => 'Api'], function ($api) {

//     // 操作员 订单核销
//     Route::post('/order/delivery', ['uses' => 'OrderController@delivery', 'as' => 'api.member.order.delivery'])->middleware('member.bind.admin:order');

//     // 操作员 扫描活动码签到
//     Route::post('/activity/singin', ['uses' => 'ActivityController@singin', 'as' => 'api.activity.singin'])->middleware('member.bind.admin:activity');

//     // 操作员 扫描用户个人码签到
//     Route::post('/activity/singin/admin', ['uses' => 'ActivityController@singinFromAdmin', 'as' => 'api.activity.singin.admin'])->middleware('member.bind.admin:activity');

//     // 操作员 订单核销记录
//     Route::post('/order/delivery/log', ['uses' => 'OrderController@getDeliveryLog', 'as' => 'api.order.delivery.log'])->middleware('member.bind.admin:activity');

//     // 操作员 我的签到记录
//     Route::post('/activity/singin/log', ['uses' => 'ActivityController@getSinginLog', 'as' => 'api.activity.singin.log'])->middleware('member.bind.admin:activity');
// });
